const Router = require('koa-router');
const router = new Router();
const tool = require('../../tools/tool')
const {db, QueryTypes} = require("../../models/db");

router.post('/menu/setOp', async ctx => {
    let body = ctx.request.body
    let roleId = body.roleId;
    let menuId = body.menuId;
    let op = body.op;
    let checked = body.checked;
    let val = checked ? 1 : 0;
    await db.query(`update role_menu set ${op}=${val} where roleId=${roleId} and menuId=${menuId}`, {type: QueryTypes.UPDATE})
    return ctx.suc('已更新');
})



module.exports = router;
